var count = 0;

function createRequestObject()
{
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();

function goScrape($url)
{
	http.open('get', $url);
	http.onreadystatechange = handleResponse;
	http.send(null);
	//repeat every 60 seconds
	setTimeout(function(){goScrape($url)}, 60000);
}

function handleResponse()
{
	if(http.readyState == 4)
	{
		var response = http.responseText;
		var update = new Array();
		if(response.indexOf('|' != -1))
		{
			count++;
			update = response.split('|');
			if(count > 20)
			{
				document.getElementById(TrimString(update[0])).innerHTML = update[1];
				count = 0;
			}
			else
			{
				document.getElementById(TrimString(update[0])).innerHTML += update[1];
			}
			document.getElementById("ScrapeCount").innerHTML = count;
		}
	}
}

function TrimString(sInString)
{
	sInString = sInString.replace( /^\s+/g, "" );// strip leading
	return sInString.replace( /\s+$/g, "" );// strip trailing
}